import { Length } from "class-validator";
import { BaseEntity } from "src/baseEntity";
import { UserSys } from "src/user/userSys.entity";
import { System } from "src/system/system.entity";
import { Column, Entity, JoinColumn, ManyToMany, ManyToOne, OneToMany, OneToOne } from "typeorm";
import { DeptRoleEnum } from "src/role/role.enum";
import { Project } from "src/project/project.entity";




@Entity("dept")
export class Dept extends BaseEntity {
    @ManyToOne(() => System, type => type.dept)
    system: System

    @Column()
    @Length(1, 20)
    name: string

    @Column({
        type: "enum",
        enum: DeptRoleEnum,
        default: DeptRoleEnum.member
    })
    deptRole: DeptRoleEnum

    @Column({ default: true, comment: "可编辑的" })
    editable: boolean

    @ManyToOne(() => Dept, { onDelete: "SET NULL" })
    parent: Dept

    @OneToMany(() => UserSys, type => type.dept)
    member: UserSys[]

    manager: UserSys
}